package algorithm.递归算法;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * @author Jun
 */
public class conversion {
    /**
     * 十进制转换
     */
    public static String conversion(int num,int base){
        String str=null;
        String charTable = "0123456789ABCDEF";
        if(num==0){
            return "";
        }
        else{
            str=conversion(num/base,base);
            return str+charTable.charAt(num%base);
        }
    }

    public static void main(String[] args) {
        try {
            int num=0;
            int base=0;
            BufferedReader br=null;
            System.out.print("请输入一个数字:");
//        Scanner in=new Scanner(System.in);
            br=new BufferedReader(new InputStreamReader(System.in));
            num=Integer.parseInt(br.readLine());
            System.out.print("请输入想要转换的进制：");
//        Scanner degit=new Scanner(System.in);
            br=new BufferedReader(new InputStreamReader(System.in));
            base=Integer.parseInt(br.readLine());
//        num=in.nextInt();
//        base=degit.nextInt();
            System.out.println(conversion(num,base));
        }catch (IOException e){
            e.getStackTrace();
        }


    }
}
